package com.eascs.ticket.project.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.ticket.common.dao.BaseDao;
import com.eascs.ticket.project.entity.ProjectVersionStatusConstant;

@Repository
public class ProjectVersionDao extends BaseDao {
	public List<Object[]> getValidProjectVersionByProjectId(String projectId) {
		return this.findObjectsList("select id,name from project_version where status!=? and project_id=?", ProjectVersionStatusConstant.DEL, projectId);
	}

	public List<Object[]> getProjectVersionByProjectId(String projectId) {
		return this.findObjectsList("select id,name from project_version where project_id=?", projectId);
	}

	public List<Object[]> getProjectVersionTableViewByProjectId(String projectId) {
		return this.findObjectsList("select id,name, DATE_FORMAT(end_time,\"%Y-%m-%d\"),publish_prod_time,publish_prod_operator,publish_prod_validated_time,publish_prod_validated_operator,status,comments from project_version where project_id=? order by end_time", projectId);
	}

	public int countProjectVersionInTicket(String projectId, String projectVersionId) {
		return this.findInteger("select count(1) from ticket where project_id=? and version_id=? ", projectId, projectVersionId);
	}
}
